package com.ukao.steward.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.steward.R;
import com.ukao.steward.base.ListBaseAdapter;
import com.ukao.steward.base.SuperViewHolder;
import com.ukao.steward.bean.WaitingOrderBean;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.util.ActivityUtils;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.widget.StateButton;

import java.util.List;

import static com.ukao.steward.R.id.pice;


public class DontSendAdapter extends ListBaseAdapter<WaitingOrderBean.ListBean> {


    private  boolean  isFinishEnter;

    public DontSendAdapter(Context context, List<WaitingOrderBean.ListBean> mDataList) {
        super(context, mDataList);
    }


    public   void  setFinishEnter(boolean  isFinishEnter  ){
        this.isFinishEnter=isFinishEnter;
    }
    @Override
    public int getLayoutId() {
        return R.layout.adapter_dont_send;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, final int position) {

        View line=holder.getView(R.id.line);
        LinearLayout payLayout=holder.getView(R.id.pay_layout);
        TextView sendAddress=holder.getView(R.id.sendAddress);
        TextView orderNo=holder.getView(R.id.orderNo);
        TextView business=holder.getView(R.id.business);
        TextView sendName=holder.getView(R.id.sendName);
        TextView sendPhone=holder.getView(R.id.sendPhone);
        TextView paymentPrice=holder.getView(R.id.paymentPrice);
        StateButton signInBtn=holder.getView(R.id.signIn_btn);
        LinearLayout sendPhoneLayout=holder.getView(R.id.sendPhone_layout);
        TextView sendNameTv=holder.getView(R.id.sendName_tv);
        TextView payStatus=holder.getView(R.id.payStatus);


        WaitingOrderBean.ListBean item = mDataList.get(position);
        sendAddress.setText(CheckUtils.isEmptyString(item.getSendAddress()));
        orderNo.setText(item.getOrderNo());

        business.setText(Constant.getbusiness(item.getBusiness()));
        sendName.setText(item.getSendName());
        sendPhone.setText(item.getSendPhone());
        sendNameTv.setText(item.getSendName());
        payStatus.setTextColor(item.getPayStatus() ? getColors(R.color.green) : getColors(R.color.red));
        payStatus.setText(item.getPayStatus()?"已付款":"未付款");

        if (isFinishEnter){
            line.setVisibility(View.GONE);
            payLayout.setVisibility(View.GONE);
        }else{
       //     signInBtn.setVisibility(item.getPayStatus() ? View.VISIBLE : View.GONE);

            if(!CheckUtils.isNull(item.getPaymentPrice())){
            //   String  pice=CheckUtils.isEmptyNumber(item.getModifyPrice());
               String  pice=CheckUtils.isEmptyNumber(item.getPaymentPrice());
                paymentPrice.setText( "￥" + pice);
                paymentPrice.setTextColor(item.getPayStatus() ? getColors(R.color.green) : getColors(R.color.red));

            }
        }

        View.OnClickListener  mOnClickListener= new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WaitingOrderBean.ListBean items = mDataList.get(position);
                switch (v.getId()){
                    case R.id.sendPhone_layout:
                        if (!CheckUtils.isEmpty(items.getSendPhone())) {
                            ActivityUtils.callActivity(mContext, items.getSendPhone());
                        }
                        break;
                    case  R.id.signIn_btn:
                        if (mOnItemChildClickListener!=null){
                            mOnItemChildClickListener.onChildItemClick(v.getId(),position, items);
                        }
                        break;
                }



            }
        };
        signInBtn.setOnClickListener(mOnClickListener);
      //  sendPhoneLayout.setOnClickListener(mOnClickListener);
    }


}
